package com.xiaobai.design_pattern.singleton;

/**
 * @author wangtw
 * @ClassName LazySingleton
 * @description: 懒汉式单例类
 * @date 2023/6/316:02
 */
public class LazySingleton {

    private static LazySingleton lazySingleton = null;

    // 构造方法私有
    private LazySingleton() {}

    // 加互斥锁
    synchronized public static LazySingleton getInstance() {
        if (lazySingleton == null) {
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }
}
